package com.fenqing.leetcode.code.t0_200.t100_200;

import com.fenqing.annotations.Execute;
import com.fenqing.core.Topic;

/**
 * @author fenqing
 */
public class Topic153 extends Topic {

    /**
     * 构造器
     *
     * @param input 输入
     */
    public Topic153(String input) {
        super(input);
    }

    @Execute
    public int findMin(int[] nums) {
        //最小的
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int pivot = (low + high) / 2;
            int pivotVal = nums[pivot];
            if (nums[high] < pivotVal) {
                low = pivot + 1;
            } else if (nums[high] > pivotVal){
                high = pivot;
            }
        }
        return nums[low];
    }

    public static void main(String[] args) {
        Topic153 topic153 = new Topic153("[3,4,5,1,2]");
        Integer run = topic153.run();
        System.out.println(run);
    }

}
